const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    img_src:app.img_src,
    tabList:[
      {t:99,n:'全部'},
      {t:0,n:'已预约'},
      {t:1,n:'已完成'},
      {t:2,n:'已取消'}
    ],
    type:88,
    title:[
      {t:'等待就诊', i:49},
      {t:'治疗完成', i:50},
      {t:'已取消', i:51},
      {t:'预约超时', i:52},
      {t:'治疗中', i:53},
    ],
    pageNo:1,
    pageSize:10,
    list:[],
    list2:[]
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (t) {
    this.setData({type:t.s || 99})
  },
  tabClick(e){
    this.setData({type:e.target.dataset.idx})
  },
  init(){
    var t = this;
    wx.showLoading()
    app.request({
      url:'https://live.sgwxmini.com/beauty/reservePush/reserveList',
      data:{
        hosId:app.api.siteinfo.hosId,
        customerId:wx.getStorageSync('customerId'),
        status:t.data.type == 99 ? '' : t.data.type,
        pageNo:t.data.pageNo,
        pageSize:t.data.pageSize
      },
      success(e){
        e.data && e.data.length && t.data.list.push(...e.data)
        e.rowNumberDate && e.rowNumberDate.length && t.data.list2.push(...e.rowNumberDate)
        e.result==0 && t.setData({
          list:t.data.list,
          list2:t.data.list2
        },wx.hideLoading)
      }
    })
  },
  onShow: function () {
    this.setData({
      pageNo: 1,
      list:[],
      list2:[]
    },this.init)
  },
  onReachBottom:function(){
    this.setData({
      pageNo: ++this.data.pageNo
    },this.init)
  },
})